package com.zy.mc_module.utils;

/**
 * Created on 18/11/1
 * 防止View重复点击,用于ButterKnife
 */
public class NoDoubleUtil {
    // 两次点击按钮之间的点击间隔不能少于220毫秒
    private static final int MIN_CLICK_DELAY_TIME = 230;
    private static long lastClickTime;

    /***
     * true:点击的时间间隔大于230毫秒,可以点击
     * false:点击的时间间隔小于230毫秒,不能点击
     */
    public static boolean isFastClick() {
        boolean flag = false;
        long curClickTime = System.currentTimeMillis();
        if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
            lastClickTime = curClickTime;
            flag = true;
        }
        return flag;
    }

    public static boolean isFastClick(int time) {
        boolean flag = false;
        long curClickTime = System.currentTimeMillis();
        if ((curClickTime - lastClickTime) >= time) {
            lastClickTime = curClickTime;
            flag = true;
        }
        return flag;
    }
}
